﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace RibbonEditor.Actions.Parameters
{
    class ParameterHelper
    {
        public static IParameter GetIParameterFromXml(XmlNode node)
        {
            IParameter param = null;

            switch(node.Name)
            {
                case "BoolParameter":
                    param = new BoolParameter(node, node.ParentNode.Name == "Url");
                    break;
                case "CrmParameter":
                    param = new CrmParameter(node, node.ParentNode.Name == "Url");
                    break;
                case "DecimalParameter":
                    param = new DecimalParameter(node, node.ParentNode.Name == "Url");
                    break;
                case "IntParameter":
                    param = new IntParameter(node, node.ParentNode.Name == "Url");
                    break;
                case "StringParameter":
                    param = new StringParameter(node, node.ParentNode.Name == "Url");
                    break;
                default:
                    throw new Exception("Unsupporter parameter type: " + node.Name);
            }

            return param;
        }
    }
}
